<%--
  Created by IntelliJ IDEA.
  User: tuhao
  Date: 2017/7/4
  Time: 9:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false"%>

<div class="bjui-pageHeader" style="background-color: #fefefe; border-bottom: none;">
    <form data-toggle="ajaxsearch" id="findglobalform" data-options="{searchDatagrid:$.CurrentNavtab.find('#pays_Ret')}">
        <fieldset>
            <legend style="font-weight:normal;">搜索：</legend>
            <div style="margin:0; padding:1px 5px 5px;">
                <span>账户名：</span>
                <input name="paysRet.account_name" size="10">&nbsp;
                <span>转账返回时间：</span>
                <input name="fromTo.from" type="text" value="${from}" data-toggle="datepicker" placeholder="点击选择日期" data-pattern="yyyy-MM-dd" readonly="true">---
                <input name="fromTo.to" type="text" value="${to}" data-toggle="datepicker" placeholder="点击选择日期" data-pattern="yyyy-MM-dd" readonly="true">&nbsp;
                <div class="btn-group">
                    <button type="submit" class="btn-green" data-icon="search">查询</button>&nbsp;
                    <button type="reset" class="btn-orange" data-icon="times">重置</button>
                </div>
            </div>
        </fieldset>
    </form>
</div>

<div class="bjui-pageContent">
    <table id="pays_Ret" class="table table-bordered">
    </table>
    <script type="text/javascript">
        var user_table;
        $(function () {
            user_table = $('#pays_Ret').datagrid({
                height: '100%',
                tableWidth: '100%',
                showToolbar: true,
                filterThead: false,
                showCheckboxcol: true,
                gridTitle : '转账返回数据列表',
                delPK: 'id',
                dataUrl: '/find_third_party_data/findPaysRet',
                local: "remote",
                inlineEditMult: false,
                saveAll: false,
                addLocation: 'last',
                toolbarCustom: function () {
                    return '<button type="button" class="btn btn-green" onclick="userListExport();" data-icon="sign-out"><i class="fa fa-sign-out"></i> 导出</button>';
                },
                delConfirm: true,
                columns: [
                    /*{
                        name:'LoanJsonList',
                        label: '转账列表',
                        align: 'center',
                        render:function (value,data) {
                            return showOne(value,data);
                        }
                    }, */{
                        name: 'PlatformMoneymoremore',
                        label: '平台乾多多标识',
                        align: 'center',
                        render:function (value,data) {
                            return showOneOfTransferRet(value,data);
                        }
                    }, {
                        name: 'Action',
                        label: '操作类型',
                        align: 'center',
                        render:function (value) {
                            var type = "";
                            if (value=="") type = "转账";
                            if (value==1) type = "通过";
                            if (value==2) type = "退回";
                            if (value==3) type = "同意二次分配";
                            if (value==4) type = "不同意二次分配";
                            return type;
                        }
                    }, {
                        name: 'RandomTimeStamp',
                        label: '随机时间戳',
                        align: 'center',
                        rule: 'required'
                    },{
                        name: 'Remark1',
                        label: '备注1(转账类型)',
                        align: 'center',
                        rule: 'required',
                        render:function (value) {
                            return value==1?"买标":"还款";
                        }
                    },{
                        name: 'Remark2',
                        label: '备注2(标号)',
                        align: 'center',
                        rule: 'required'
                    },{
                        name: 'Remark3',
                        label: '备注3',
                        align: 'center',
                        rule: 'required'
                    },{
                        name: 'ResultCode',
                        label: '返回码',
                        align: 'center',
                        rule: 'required'
                    },{
                        name: 'Message',
                        label: '返回信息',
                        align: 'center',
                        rule: 'required'
                    },{
                        name: 'ReturnTimes',
                        label: '返回次数',
                        align: 'center',
                        rule: 'required',
                        render:function (value, data) {
                            return showListOfTransferRet(value,data);
                        }
                    },/*{
                        name: 'SignInfo',
                        label: '签名信息',
                        align: 'center',
                        rule: 'required'
                    }, */{
                        name: 'date',
                        label: '转账返回时间',
                        align: 'center',
                        pattern: 'yyyy-MM-dd HH:mm:ss',
                        render: function (value) {
                            return value ? value.substr(0, 19) : value
                        }
                    }
                ],
                linenumberAll: true,
                paging: {pageSize:20,pageCurrent:1}
            });
        });


        function showListOfTransferRet(value,data) {

            return '<a href="javascript:;" onclick="showListTransferRet(\''+ data.LoanJsonList +'\')">'+ value + '</a>';
        }

        function showListTransferRet(value) {

            value = encodeURIComponent(value);
            BJUI.dialog({
                id:'info_'+ new Date().getTime(),
                url:'/find_third_party_data/transferReturnCount?transferRet.loanJsonList='+value,
                title:'查看详情',
                width: 1200,
                height: 1200 * 0.618
            });
        }

        function showOneOfTransferRet(value,data) {

            return '<a href="javascript:;" onclick="showOneTransferRet(\''+ data.id +'\')">'+ value + '</a>';
        }

        function showOneTransferRet(value) {

            BJUI.dialog({
                id:'info_'+value,
                url:'/find_third_party_data/findPaysOneRet?paysRet.id='+value,
                title:'查看详情',
                width: 1200,
                height: 1200 * 0.618
            });
        }

        function userListExport() {
            var dates = $(user_table).data('selectedDatas');
            if (dates && dates.length !== 0) {
                var ids = [];
                dates.forEach(function (e) {
                    ids.push(e.id);
                });
                BJUI.ajax('ajaxdownload', {
                    url: '/export/exportOpenAccountRet',
                    data: {ids: ids.join(",")}
                });
            } else
                BJUI.alertmsg('info', BJUI.getRegional('datagrid.selectMsg'))
        }
    </script>
</div>